package com.example.auth.validator;

import cn.hutool.core.lang.Validator;
import com.example.auth.annotation.PhoneNumber;
import org.apache.commons.lang3.StringUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;

public class PhoneNumberValidator implements ConstraintValidator<PhoneNumber, String> {
	@Override
	public boolean isValid(String phoneField, ConstraintValidatorContext context) {
		if (StringUtils.isBlank(phoneField)) return true;
		return Validator.isMobile(phoneField);
	}
}
